package com.att.action;

import com.adkfp.utils.LayuiUtil;
import com.att.bean.*;
import com.att.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@Controller
@RequestMapping("accessLog")
public class AccessLogAction {

    @Resource(name = "accessLogService")
    private AccessLogService accessLogService;
    @Resource(name = "holidaysService")
    private HolidaysService holidaysService;
    @Resource(name = "userOfRunService")
    private UserOfRunService userOfRunService;
    @Resource(name = "numRunService")
    private NumRunService numRunService;
    @Resource(name = "paramService")
    private ParamService paramService;
    @Resource(name = "userSpedayService")
    private UserSpedayService userSpedayService;
    @Resource(name = "checkInOutService")
    private CheckInOutService checkInOutService;
    @Resource(name = "userOfRunDeilService")
    private UserOfRunDeilService userOfRunDeilService;
    @Resource(name = "leaveClassService")
    private LeaveClassService leaveClassService;

    /**
     * Description: 转发到出勤记录页面
     */
    @RequestMapping("accessLogIndex")
    public String accessLogIndex() {
        return "printing/attendance_record";
    }

    /**
     * Description: 转发到在岗情况页面
     */
    @RequestMapping("stationIndex")
    public String stationIndex() {
        return "printing/station";
    }

    /**
     * Description: 转发到统计报表页面
     */
    @RequestMapping("statisticalIndex")
    public String statisticalIndex() {
        return "printing/statistical";
    }

    /**
     * Description: 带条件查询出勤记录
     *
     * @param bean
     */
    @RequestMapping("selectAll")
    @ResponseBody
    public Object selectAll(AccessLogBean bean) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat format2 = new SimpleDateFormat("HH:mm:ss");
        List<AccessLogBean> list = accessLogService.findByCondition(bean);
        for (int i = 0; i < list.size(); i++) {
            DateFormat df3 = DateFormat.getTimeInstance();
            Date eventTime = format.parse(list.get(i).getEventTime());
            Date b = format2.parse(df3.format(eventTime));
            Long a = b.getTime();
            if (list.get(i).getCheckType() != null) {
                list.get(i).setEventSource(4);
            }
            if (list.get(i).getCheckInTime1() != null && list.get(i).getCheckInTime2() != null && list.get(i).getCheckOutTime1() != null) {
                Date date1 = format2.parse(df3.format(list.get(i).getCheckInTime1()));
                Long c = date1.getTime();
                Date date2 = format2.parse(df3.format(list.get(i).getCheckInTime2()));
                Long d = date2.getTime();
                Date time1 = format2.parse(df3.format(list.get(i).getCheckOutTime1()));
                Long e = time1.getTime();
                Date time2 = format2.parse(df3.format(list.get(i).getCheckOutTime2()));
                Long f = time2.getTime();
                if (a >= c && a <= d) {
                    list.get(i).setCheckType(0);
                } else if (a >= e && a <= f) {
                    list.get(i).setCheckType(1);
                } else {
                    list.get(i).setCheckType(2);
                }
            }
        }
        List<AccessLogBean> count = accessLogService.findByConditionCount(bean);
        return LayuiUtil.data(Long.valueOf(count.size()), list);
    }


    /**
     * Description: 带条件查询当前在岗情况
     *
     * @param bean
     */
    @RequestMapping("selectStation")
    @ResponseBody
    public Object selectStation(AccessLogBean bean) {
        List<AccessLogBean> list = accessLogService.findStationByCondition(bean);
        List<AccessLogBean> count = accessLogService.findStationByConCount(bean);
        return LayuiUtil.data(Long.valueOf(count.size()), list);
    }


    /**
     * Description: 带条件查询异常情况
     *
     * @param bean
     */
    @RequestMapping("selectError")
    @ResponseBody
    public Object selectError(AccessLogBean bean) throws ParseException {
        long nd = 1000 * 24 * 60 * 60;
        long nh = 1000 * 60 * 60;
        long nm = 1000 * 60;
        List<AccessLogBean> arrayList = new ArrayList<>();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat format2 = new SimpleDateFormat("HH:mm:ss");
        ParamBean paramBean = new ParamBean();
        List<ParamBean> paramBeanList = paramService.findByCondition(paramBean);
        List<AccessLogBean> list = accessLogService.findAccessLogErrorCondition(bean);
        for (int i = 0; i < list.size(); i++) {
            String startTime = format2.format(list.get(i).getStartTime());
            String endTime = format2.format(list.get(i).getEndTime());
            String dayTime = format.format(list.get(i).getStartTime());
            list.get(i).setStartTimeStr(startTime.substring(0, startTime.lastIndexOf(":")));
            list.get(i).setEndTimeStr(endTime.substring(0, endTime.lastIndexOf(":")));
            list.get(i).setDayTime(dayTime);
            // 获得两个时间的毫秒时间差异
            long diff = list.get(i).getEndTime().getTime() - list.get(i).getStartTime().getTime();
            // 计算差多少小时
            String hour = String.valueOf(diff % nd / nh);
            // 计算差多少分钟
            String min = String.valueOf(diff % nd % nh / nm);
            if (hour.length() == 1) {
                list.get(i).setTimeSum("0" + hour + ":" + min);
                if (min.length() == 1) {
                    list.get(i).setTimeSum("0" + hour + ":" + "0" + min);
                }
            } else {
                list.get(i).setTimeSum(hour + ":" + min);
                if (min.length() == 1) {
                    list.get(i).setTimeSum(hour + ":" + "0" + min);
                }
            }
            UserOfRunBean userOfRunBean = new UserOfRunBean();
            if (list.get(i).getUserId() != null) {
                userOfRunBean.setUserId(list.get(i).getUserId());
                List<UserOfRunBean> runBeanList = userOfRunService.findUserOfRunBean(userOfRunBean);
                for (int j = 0; j < runBeanList.size(); j++) {
                    if (list.get(i).getStartTime().after(runBeanList.get(j).getStartTime()) && list.get(i).getEndTime().before(runBeanList.get(j).getEndTime())) {
                        long num = list.get(i).getEndTime().getTime() - list.get(i).getStartTime().getTime();
                        int days = (int) (num / (1000 * 60 * 60 * 24));
                        if (days <= 0) {
                            long nums = runBeanList.get(j).getEndTime().getTime() - runBeanList.get(j).getStartTime().getTime();
                            long hours = nums % nd / nh;
                            long h = Long.valueOf(hour);
                            if (h > hours) {
                                list.get(i).setDays(days + 1);
                            } else {
                                list.get(i).setDays(days);
                            }
                        } else {
                            list.get(i).setDays(days);
                        }
                    }
                }
            }
            Date endDate = format.parse(format.format(list.get(i).getEndTime()));
            Date startDate = format.parse(format.format(list.get(i).getStartTime()));
            int days = (int) ((endDate.getTime() - startDate.getTime()) / (1000 * 3600 * 24));
            days = days + 1;
            Calendar cal = Calendar.getInstance();
            for (int j = 0; j < days; j++) {
                if (j == 0) {
                    cal.setTime(list.get(i).getStartTime());
                } else if (j > 0 && days > 1) {
                    cal.setTime(list.get(i).getStartTime());
                    cal.add(Calendar.DAY_OF_MONTH, 1);
                }
                list.get(i).setDayTime(format.format(cal.getTime()));
                AccessLogBean logBean = new AccessLogBean();
                logBean.setDayTime(list.get(i).getDayTime());
                logBean.setUserName(list.get(i).getUserName());
                logBean.setUserId(list.get(i).getUserId());
                logBean.setStartTimeStr(list.get(i).getStartTimeStr());
                logBean.setEndTimeStr(list.get(i).getEndTimeStr());
                logBean.setTimeSum(list.get(i).getTimeSum());
                logBean.setLeaveName(list.get(i).getLeaveName());
                logBean.setDays(list.get(i).getDays());
                if (list.get(i).getUserId() != null) {
                    UserOfRunBean user = new UserOfRunBean();
                    user.setUserId(list.get(i).getUserId());
                    List<UserOfRunBean> beanList = userOfRunService.findUserOfRunList(user);
                    for (int k = 0; k < beanList.size(); k++) {
                        Date start = format2.parse(startTime);
                        Date end = format2.parse(endTime);
                        Date startTime2 = beanList.get(0).getStartTime();
                        Date endTime2 = beanList.get(0).getEndTime();
                        if (start.compareTo(startTime2) == 0 || start.before(startTime2) && (end.compareTo(endTime2) == 0 || end.after(endTime2))) {
//                            if (end.compareTo(endTime2) == 0 || end.compareTo(beanList.get(0).getEndTime()) == -1) {
                            // 获得两个时间的毫秒时间差异
//                                long time = end.getTime() - beanList.get(0).getStartTime().getTime();
                            // 计算差多少小时
//                                String hours = String.valueOf(time % nd / nh);
                            // 计算差多少分钟
//                                String mins = String.valueOf(time % nd % nh / nm);
                            int time = paramBeanList.get(0).getWorkdayTime();
                            String hours = String.valueOf((int) Math.floor(time / 60));
                            String mins = String.valueOf(time % 60);
                            if (hours.length() == 1) {
                                list.get(i).setTims("0" + hours + ":" + mins);
                                if (mins.length() == 1) {
                                    list.get(i).setTims("0" + hours + ":" + "0" + mins);
                                }
                            } else {
                                list.get(i).setTims(hours + ":" + mins);
                            }
                        } else {
                            if (start.compareTo(startTime2) == 0 || start.after(startTime2)) {
                                // 获得两个时间的毫秒时间差异
                                long time = start.getTime() - startTime2.getTime();
                                // 计算差多少小时
                                String hours = String.valueOf(time % nd / nh);
                                // 计算差多少分钟
                                String mins = String.valueOf(time % nd % nh / nm);

                                if (hours.length() == 1) {
                                    list.get(i).setTims("0" + hours + ":" + mins);
                                    if (mins.length() == 1) {
                                        list.get(i).setTims("0" + hours + ":" + "0" + mins);
                                    }
                                } else {
                                    list.get(i).setTims(hours + ":" + mins);
                                }
                            } else if ((start.compareTo(startTime2) == 0 || start.before(startTime2)) && (end.compareTo(endTime2) == 0 || end.before(endTime2))) {
//                             获得两个时间的毫秒时间差异
                                long time = endTime2.getTime() - end.getTime();
//                             计算差多少小时
                                long hours = time % nd / nh;
//                             计算差多少分钟
                                long mins = time % nd % nh / nm;
                                int workdayTime = paramBeanList.get(0).getWorkdayTime();
                                long workdayHours = workdayTime / 60;
                                long workdayMins = workdayTime % 60;
                                if (workdayMins == 0) {
                                    workdayMins = 60;
                                    hours = workdayHours - 1;
                                    mins = workdayMins - mins;
                                }
                                if (String.valueOf(hours).length() == 1) {
                                    list.get(i).setTims("0" + hours + ":" + mins);
                                    if (String.valueOf(mins).length() == 1) {
                                        list.get(i).setTims("0" + hours + ":" + "0" + mins);
                                    }
                                } else {
                                    list.get(i).setTims(hours + ":" + mins);
                                }
                            }
                        }
                        if (list.get(i).getTimeSum().equals("00:00")) {
                            list.get(i).setTims("00:00");
                        }
                    }
                }

//                ParamBean paramBean = new ParamBean();
//                List<ParamBean> paramBeanList = paramService.findByCondition(paramBean);
//                int time = paramBeanList.get(0).getWorkdayTime();
//                String hours = String.valueOf((int) Math.floor(time / 60));
//                String minute = String.valueOf(time % 60);
//                if (hours.length() == 1) {
//                    list.get(i).setTims("0" + hours + ":" + minute);
//                    if (minute.length() == 1) {
//                        list.get(i).setTims("0" + hours + ":" + "0" + minute);
//                    }
//                } else {
//                    list.get(i).setTims(hours + ":" + minute);
//                }
                logBean.setTims(list.get(i).getTims());
                arrayList.add(logBean);
            }
        }
        List<AccessLogBean> count = accessLogService.findAccessLogErrorCount(bean);
        return LayuiUtil.data(Long.valueOf(arrayList.size()), arrayList);
    }

    /**
     * Description: 带条件查询考勤统计汇总
     *
     * @param bean
     */
    @RequestMapping("selectCount")
    @ResponseBody
    public Object selectCount(AccessLogBean bean) throws ParseException {
        long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数
        long nh = 1000 * 60 * 60;// 一小时的毫秒数
        long nm = 1000 * 60;// 一分钟的毫秒数
        long ns = 1000;// 一秒钟的毫秒数
        List<AccessLogBean> arrayList = new ArrayList<>();
        Calendar cal = Calendar.getInstance();
        NumberFormat ddf1 = NumberFormat.getNumberInstance();
        ddf1.setMaximumFractionDigits(2);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat format2 = new SimpleDateFormat("HH:mm:ss");
        SimpleDateFormat format3 = new SimpleDateFormat("yyyy-MM-dd");
        Date start = bean.getStartTime();
        Date end = bean.getEndTime();
        ParamBean paramBean = new ParamBean();
        List<ParamBean> paramBeanList = paramService.findByCondition(paramBean);
        List<AccessLogBean> list = accessLogService.findAccessLogCountCondition(bean);
        for (int i = 0; i < list.size(); i++) {
            Integer shouldArrive = 0;//应到
            Integer trueArrive = 0;//实到
            Integer lateArrive = 0;//迟到
            long lateArriveTime = 0;//迟到时间
            Integer leaveEarly = 0;//早退
            long leaveEarlyTime = 0;//早退时间
            Integer absenteeism = 0;//旷工
            Integer workMins = 0;//记多少分钟
            Integer signIn = 0;//签到
            Integer signBack = 0;//签退
            Integer weekday = 0;//平日
            Integer weekend = 0;//周末
            Integer holiday = 0;//节假日
            long leaveClass = 0;//请假
            long isOut = 0;//外出
            Integer goOut = 0;//公出
            long thingLeave = 0;//事假
            long sickLeave = 0;//病假
            long familyLeave = 0;//探亲假
            Integer addWorkTime = 0;
            double attendanceTime = 0;//出勤时间
            long weekdayAddTime = 0;//平日加班时间
            long weekendAddTime = 0;//周末加班时间
            long holidayAddTime = 0;//节假日加班时间
            if (start != null && end != null) {
                String userID = list.get(i).getUserId();
                UserOfRunDeilBean runDeilBean = new UserOfRunDeilBean();
                runDeilBean.setUserId(userID);
                runDeilBean.setsTime(start);
                runDeilBean.setEndTime(end);
                List<UserOfRunDeilBean> runDeilList = userOfRunDeilService.findUserOfRunDeilBean(runDeilBean);
                shouldArrive += runDeilList.size();
                DateFormat df3 = DateFormat.getTimeInstance();
                Date runStartTime = list.get(i).getRunStartTime();
                Date runEndTime = list.get(i).getRunEndTime();
                if (runStartTime != null && runEndTime != null) {
                    if (end.compareTo(new Date()) == 0 || end.before(new Date())) {
                        if ((start.compareTo(runStartTime) == 0 || start.after(runStartTime)) && (end.compareTo(runEndTime) == 0 || end.before(runEndTime))) {
                            absenteeism += shouldArrive;
                        } else if ((start.compareTo(runStartTime) == 0 || start.before(runStartTime)) && (end.compareTo(runEndTime) == 0 || end.after(runEndTime))) {
                            runDeilBean.setsTime(runStartTime);
                            runDeilBean.setEndTime(runEndTime);
                            List<UserOfRunDeilBean> userofrun = userOfRunDeilService.findUserOfRunDeilBean(runDeilBean);
                            absenteeism += userofrun.size();
                        } else if ((start.compareTo(runStartTime) == 0 || start.before(runStartTime)) && (end.compareTo(runEndTime) == 0 || end.before(runEndTime))) {
                            runDeilBean.setsTime(runStartTime);
                            runDeilBean.setEndTime(end);
                            List<UserOfRunDeilBean> userofrun = userOfRunDeilService.findUserOfRunDeilBean(runDeilBean);
                            absenteeism += userofrun.size();
                        } else if ((start.compareTo(runStartTime) == 0 || start.after(runStartTime)) && (end.compareTo(runEndTime) == 0 || end.after(runEndTime))) {
                            runDeilBean.setsTime(start);
                            runDeilBean.setEndTime(runEndTime);
                            List<UserOfRunDeilBean> userofrun = userOfRunDeilService.findUserOfRunDeilBean(runDeilBean);
                            absenteeism += userofrun.size();
                        }
                    } else {
                        if ((start.compareTo(runStartTime) == 0 || start.after(runStartTime)) && (end.compareTo(runEndTime) == 0 || end.before(runEndTime))) {
                            absenteeism += shouldArrive;
                        } else if ((start.compareTo(runStartTime) == 0 || start.before(runStartTime)) && (end.compareTo(runEndTime) == 0 || end.after(runEndTime))) {
                            runDeilBean.setsTime(runStartTime);
                            runDeilBean.setEndTime(runEndTime);
                            List<UserOfRunDeilBean> userofrun = userOfRunDeilService.findUserOfRunDeilBean(runDeilBean);
                            absenteeism += userofrun.size();
                        } else if ((start.compareTo(runStartTime) == 0 || start.before(runStartTime)) && (end.compareTo(runEndTime) == 0 || end.before(runEndTime))) {
                            runDeilBean.setsTime(runStartTime);
                            runDeilBean.setEndTime(new Date());
                            List<UserOfRunDeilBean> userofrun = userOfRunDeilService.findUserOfRunDeilBean(runDeilBean);
                            absenteeism += userofrun.size();
                        } else if ((start.compareTo(runStartTime) == 0 || start.after(runStartTime)) && (end.compareTo(runEndTime) == 0 || end.after(runEndTime))) {
                            runDeilBean.setsTime(start);
                            runDeilBean.setEndTime(new Date());
                            List<UserOfRunDeilBean> userofrun = userOfRunDeilService.findUserOfRunDeilBean(runDeilBean);
                            absenteeism += userofrun.size();
                        }
                    }

                    AccessLogBean accessLogBean = new AccessLogBean();
                    accessLogBean.setUserID(userID);
                    List<AccessLogBean> list1 = accessLogService.findAccessLogBean(accessLogBean);
                    for (int j = 0; j < list1.size(); j++) {
                        if (list1.get(j).getEventTime() != null) {
                            Date eventTime = format.parse(list1.get(j).getEventTime());//打卡事件
                            if ((eventTime.compareTo(start) == 0 || eventTime.after(start)) && (eventTime.compareTo(end) == 0 || eventTime.before(end))) {
                                if (list.get(i).getCheckInTime1() != null && list.get(i).getCheckInTime2() != null && list.get(i).getCheckOutTime1() != null && list.get(i).getCheckOutTime2() != null) {
                                    Date checkInTime1 = format2.parse(df3.format(list.get(i).getCheckInTime1()));
                                    Date checkInTime2 = format2.parse(df3.format(list.get(i).getCheckInTime2()));
                                    Date checkOutTime1 = format2.parse(df3.format(list.get(i).getCheckOutTime1()));
                                    Date checkOutTime2 = format2.parse(df3.format(list.get(i).getCheckOutTime2()));
                                    Date startTime = format2.parse(df3.format(list.get(i).getStartTime()));
                                    //判断是否为周六日
                                    if (list.get(i).getUnits() != null && list.get(i).getUnits() == 1) {
                                        cal.setTime(eventTime);
                                        int week = cal.get(Calendar.DAY_OF_WEEK) - 1;
                                        runDeilBean.setsTime(null);
                                        runDeilBean.setEndTime(null);
                                        runDeilBean.setStartTime(format3.parse(list1.get(j).getEventTime()));
                                        List<UserOfRunDeilBean> deilBeanList = userOfRunDeilService.findUserOfRunDeilBean(runDeilBean);
                                        if (week != 0 && week != 6) {//0为周日，6为周六
                                            Date eventDate = format2.parse(df3.format(eventTime));
                                            if (deilBeanList != null && deilBeanList.size() > 0) {

                                                if (list.get(i).getStartTime() != null && list.get(i).getCheckInTime2() != null) {
                                                    cal.setTime(list.get(i).getStartTime());
                                                    if (paramBeanList != null && paramBeanList.get(0).getOverTime() != null) {
                                                        cal.add(Calendar.MINUTE, paramBeanList.get(0).getOverTime());
                                                    }
                                                    Date startdate = format2.parse(df3.format(cal.getTime()));
                                                    Date endDate = format2.parse(df3.format(list.get(i).getCheckInTime2()));
                                                    if (eventDate.after(startdate) && eventDate.before(endDate)) {
                                                        lateArrive++;
                                                        lateArriveTime += eventDate.getTime() - list.get(i).getStartTime().getTime();
                                                        int min = (int) lateArriveTime / 60000;
                                                        if(min >= paramBeanList.get(0).getAbsenteeism()){
                                                            trueArrive = trueArrive-1;
                                                        }
                                                    }
                                                }
                                                Date eventDate2 = format2.parse(df3.format(eventTime));
                                                if (list.get(i).getCheckOutTime1() != null && list.get(i).getEndTime() != null) {
                                                    cal.setTime(list.get(i).getEndTime());
                                                    if (paramBeanList != null && paramBeanList.get(0).getOffWorkTime() != null) {
                                                        cal.set(Calendar.MINUTE, -paramBeanList.get(0).getOffWorkTime());
                                                    }
                                                    Date startdate2 = format2.parse(df3.format(cal.getTime()));
                                                    Date endDate2 = format2.parse(df3.format(list.get(i).getEndTime()));
                                                    if (eventDate2.after(checkOutTime1) && eventDate2.before(startdate2)) {
                                                        leaveEarly++;
                                                        leaveEarlyTime += eventDate2.getTime() - endDate2.getTime();
                                                    }
                                                }
                                                if (checkInTime1 != null && checkInTime2 != null) {
                                                    if ((eventDate2.compareTo(checkInTime1) == 0 || eventDate2.after(checkInTime1)) && (eventDate2.compareTo(checkInTime2) == 0 || eventDate2.before(checkInTime2))) {
                                                        list.get(i).setStartTimeStr(format2.format(eventDate2));
                                                        signIn++;
                                                    }
                                                }
                                                if (checkOutTime1 != null && checkOutTime2 != null) {
                                                    if (list1.get(j).getCheckType() == null) {
                                                        list1.get(j).setCheckType(1);
                                                    }
                                                    if ((eventDate2.compareTo(checkOutTime1) == 0 || eventDate2.after(checkOutTime1)) && (eventDate2.compareTo(checkOutTime2) == 0 || eventDate2.before(checkOutTime2)) && list1.get(j).getCheckType() == 1) {
                                                        list.get(i).setEndTimeStr(format2.format(eventDate2));
                                                        if (list.get(i).getStartTimeStr() != null && list.get(i).getEndTimeStr() != null) {
                                                            double num3 = format2.parse(list.get(i).getEndTimeStr()).getTime() - format2.parse(list.get(i).getStartTimeStr()).getTime();
                                                            // 计算差多少小时
                                                            double hour3 = num3 % nd / nh;
                                                            attendanceTime += hour3;
                                                        }
                                                        signBack++;
                                                    }
                                                }

                                                if (j > 0) {
//                                                    if (!format3.parse(list1.get(j).getEventTime()).equals(format3.parse(list1.get(j - 1)
//                                                            .getEventTime()))) {
                                                    if (paramBeanList.get(0).getOffDutyNoAttend() == 1) {
                                                        if ((eventDate.compareTo(checkInTime1) == 0 || eventDate.after(checkInTime1)) && (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2))) {
                                                            trueArrive++;
                                                            weekday++;
                                                            workMins += list.get(i).getWorkMins();
                                                        } else if (checkInTime1.compareTo(checkOutTime2) == 1) {
                                                            if ((eventDate.compareTo(checkInTime1) == 0 || eventDate.after(checkInTime1)) || (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2))) {
                                                                trueArrive++;
                                                                weekday++;
                                                                workMins += list.get(i).getWorkMins();
                                                            }
                                                        }
                                                    } else if (paramBeanList.get(0).getOffDutyNoAttend() == 2) {
                                                        if (list1.get(j).getCheckType() == null) {
                                                            list1.get(j).setCheckType(1);
                                                        }
                                                        if ((eventDate.compareTo(checkOutTime1) == 0 || eventDate.after(checkOutTime1)) && (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2)) && list1.get(j).getCheckType() == 1) {
                                                            trueArrive++;
                                                            weekday++;
                                                            workMins += list.get(i).getWorkMins();
                                                        }
                                                    }
//                                                    } else {
//                                                        continue;
//                                                    }
                                                } else {
                                                    if (paramBeanList.get(0).getOffDutyNoAttend() == 1) {
                                                        if ((eventDate.compareTo(checkInTime1) == 0 || eventDate.after(checkInTime1)) && (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2))) {
                                                            trueArrive++;
                                                            weekday++;
                                                            workMins += list.get(i).getWorkMins();
                                                        } else if (checkInTime1.compareTo(checkOutTime2) == 1) {
                                                            if ((eventDate.compareTo(checkInTime1) == 0 || eventDate.after(checkInTime1)) || (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2))) {
                                                                trueArrive++;
                                                                workMins += list.get(i).getWorkMins();
                                                            }
                                                        }
                                                    } else if (paramBeanList.get(0).getOffDutyNoAttend() == 2) {
                                                        if (list1.get(j).getCheckType() == null) {
                                                            list1.get(j).setCheckType(1);
                                                        }
                                                        if ((eventDate.compareTo(checkOutTime1) == 0 || eventDate.after(checkOutTime1)) && (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2)) && list1.get(j).getCheckType() == 1) {
                                                            trueArrive++;
                                                            weekday++;
                                                            workMins += list.get(i).getWorkMins();
                                                        }
//                                                        else if(checkInTime1.compareTo(checkOutTime2) == 1){
//                                                            if ((eventDate.compareTo(checkInTime1) == 0 || eventDate.after(checkInTime1)) || (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2))) {
//                                                                trueArrive++;
//                                                                workMins += list.get(i).getWorkMins();
//                                                            }
//                                                        }
                                                    }
                                                }
                                            }
                                            if(list.get(i).getSchName() != null){
                                                if(list.get(i).getSchName().equals("加班")){
                                                    weekdayAddTime = 9;
                                                }
                                            }
                                        } else {
                                            Date eventDate = format2.parse(df3.format(eventTime));
                                            Date startdate = format2.parse(df3.format(list.get(i).getCheckInTime1()));
                                            Date endDate = format2.parse(df3.format(list.get(i).getCheckOutTime2()));
                                            if (deilBeanList != null && deilBeanList.size() > 0) {
                                                if ((eventDate.compareTo(startdate) == 0 || eventDate.after(startdate)) && (eventDate.compareTo(endDate) == 0 || eventDate.before(endDate))) {
                                                    weekend++;
                                                }
                                            }
                                        }
                                    } else {
                                        Date eventDate = format2.parse(df3.format(eventTime));
                                        runDeilBean.setsTime(null);
                                        runDeilBean.setEndTime(null);
                                        runDeilBean.setStartTime(format3.parse(list1.get(j).getEventTime()));
                                        List<UserOfRunDeilBean> deilBeanList = userOfRunDeilService.findUserOfRunDeilBean(runDeilBean);
                                        if (deilBeanList != null && deilBeanList.size() > 0) {

                                            if (list.get(i).getStartTime() != null && list.get(i).getCheckInTime2() != null) {
                                                cal.setTime(list.get(i).getStartTime());
                                                if (paramBeanList != null && paramBeanList.get(0).getOverTime() != null) {
                                                    cal.add(Calendar.MINUTE, paramBeanList.get(0).getOverTime());
                                                }

                                                Date startdate = format2.parse(df3.format(cal.getTime()));
                                                Date endDate = format2.parse(df3.format(list.get(i).getCheckInTime2()));
                                                if (eventDate.after(startdate) && eventDate.before(endDate)) {
                                                    lateArrive++;
                                                    lateArriveTime += eventDate.getTime() - list.get(i).getStartTime().getTime();
                                                    int min = (int) lateArriveTime / 60000;
                                                    if(min >= paramBeanList.get(0).getAbsenteeism()){
                                                        trueArrive = trueArrive-1;
                                                    }
                                                }
                                            }
                                            Date eventDate2 = format2.parse(df3.format(eventTime));
                                            if (list.get(i).getCheckOutTime1() != null && list.get(i).getEndTime() != null) {
                                                cal.setTime(list.get(i).getEndTime());
                                                if (paramBeanList != null && paramBeanList.get(0).getOffWorkTime() != null) {
                                                    cal.set(Calendar.MINUTE, -paramBeanList.get(0).getOffWorkTime());
                                                }
                                                Date startdate2 = format2.parse(df3.format(cal.getTime()));
                                                Date endDate2 = format2.parse(df3.format(list.get(i).getEndTime()));
                                                if (eventDate2.after(checkOutTime1) && eventDate2.before(startdate2)) {
                                                    leaveEarly++;
                                                    leaveEarlyTime += eventDate2.getTime() - endDate2.getTime();
                                                }
                                            }
                                            if (checkInTime1 != null && checkInTime2 != null) {
                                                if ((eventDate2.compareTo(checkInTime1) == 0 || eventDate2.after(checkInTime1)) && (eventDate2.compareTo(checkInTime2) == 0 || eventDate2.before(checkInTime2))) {
                                                    signIn++;
                                                }
                                            }
                                            if (checkOutTime1 != null && checkOutTime2 != null) {
                                                if (list1.get(j).getCheckType() == null) {
                                                    list1.get(j).setCheckType(1);
                                                }
                                                if ((eventDate2.compareTo(checkOutTime1) == 0 || eventDate2.after(checkOutTime1)) && (eventDate2.compareTo(checkOutTime2) == 0 || eventDate2.before(checkOutTime2)) && list1.get(j).getCheckType() == 1) {
                                                    list.get(i).setEndTimeStr(format2.format(eventDate2));
                                                    if (list.get(i).getStartTimeStr() != null && list.get(i).getEndTimeStr() != null) {
                                                        double num3 = format2.parse(list.get(i).getEndTimeStr()).getTime() - format2.parse(list.get(i).getStartTimeStr()).getTime();
                                                        // 计算差多少小时
                                                        double hour3 = num3 % nd / nh;
                                                        attendanceTime += hour3;
                                                    }
                                                    signBack++;
                                                }
                                            }

                                            if (j > 0) {
//                                                if (!format3.parse(list1.get(j).getEventTime()).equals(format3.parse(list1.get(j - 1)
//                                                        .getEventTime()))) {
                                                if (paramBeanList.get(0).getOffDutyNoAttend() == 1) {
                                                    if ((eventDate.compareTo(checkInTime1) == 0 || eventDate.after(checkInTime1)) && (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2))) {
                                                        trueArrive++;
                                                        weekday++;
                                                        workMins += list.get(i).getWorkMins();
                                                    } else if (checkInTime1.compareTo(checkOutTime2) == 1) {
                                                        if ((eventDate.compareTo(checkInTime1) == 0 || eventDate.after(checkInTime1)) || (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2))) {
                                                            trueArrive++;
                                                            weekday++;
                                                            workMins += list.get(i).getWorkMins();
                                                        }
                                                    }
                                                } else if (paramBeanList.get(0).getOffDutyNoAttend() == 2) {
                                                    if ((eventDate.compareTo(checkOutTime1) == 0 || eventDate.after(checkOutTime1)) && (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2))) {
                                                        trueArrive++;
                                                        weekday++;
                                                        workMins += list.get(i).getWorkMins();
                                                    }
                                                }
//                                                } else {
//                                                    continue;
//                                                }
                                            } else {
                                                if (paramBeanList.get(0).getOffDutyNoAttend() == 1) {
                                                    if ((eventDate.compareTo(checkInTime1) == 0 || eventDate.after(checkInTime1)) && (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2))) {
                                                        trueArrive++;
                                                        weekday++;
                                                        workMins += list.get(i).getWorkMins();
                                                    } else if (checkInTime1.compareTo(checkOutTime2) == 1) {
                                                        if ((eventDate.compareTo(checkInTime1) == 0 || eventDate.after(checkInTime1)) || (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2))) {
                                                            trueArrive++;
                                                            workMins += list.get(i).getWorkMins();
                                                        }
                                                    }
                                                } else if (paramBeanList.get(0).getOffDutyNoAttend() == 2) {
                                                    if ((eventDate.compareTo(checkOutTime1) == 0 || eventDate.after(checkOutTime1)) && (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2))) {
                                                        trueArrive++;
                                                        weekday++;
                                                        workMins += list.get(i).getWorkMins();
                                                    }
//                                                        else if(checkInTime1.compareTo(checkOutTime2) == 1){
//                                                            if ((eventDate.compareTo(checkInTime1) == 0 || eventDate.after(checkInTime1)) || (eventDate.compareTo(checkOutTime2) == 0 || eventDate.before(checkOutTime2))) {
//                                                                trueArrive++;
//                                                                workMins += list.get(i).getWorkMins();
//                                                            }
//                                                        }
                                                }
                                            }


                                        }
                                    }
                                }
                            }
                        }
                    }
                    UserSpedayBean userSpedayBean = new UserSpedayBean();
                    userSpedayBean.setUserId(userID);
                    userSpedayBean.setStartTime(start);
                    userSpedayBean.setEndTime(end);
                    List<LeaveClassBean> leaveClassBeanList = leaveClassService.findByCondition();
                    List<UserSpedayBean> spedayBeanList = userSpedayService.findUserSpedayBeanList(userSpedayBean);

                    List<AccessLogTemp> tempArrayList = new ArrayList<>();
                    for (int k = 0; k < spedayBeanList.size(); k++) {
                        int time = paramBeanList.get(0).getWorkdayTime();
                        int hour = (int) Math.floor(time / 60);
                        int minute = time % 60;
//                        leaveClass += hour;
//                        Date spedayStart = format3.parse(format3.format(spedayBeanList.get(k).getStartTime()));
//                        Date spedayEnd = format3.parse(format3.format(spedayBeanList.get(k).getEndTime()));
//                        int days = (int) ((spedayEnd.getTime() - spedayStart.getTime())/(1000*3600*24));
//                        for (int g = 0;g<days;g++){
//                            leaveClass += hour;
//                        }
                        String startTime = format2.format(spedayBeanList.get(k).getStartTime());
                        String endTime = format2.format(spedayBeanList.get(k).getEndTime());


                        if (list.get(i).getUserId() != null) {
                            UserOfRunBean user = new UserOfRunBean();
                            user.setUserId(list.get(i).getUserId());
                            List<UserOfRunBean> beanList = userOfRunService.findUserOfRunList(user);
                            for (int g = 0; g < beanList.size(); g++) {
                                Date spedayStart = format2.parse(startTime);
                                Date spedayEnd = format2.parse(endTime);
                                Date startTime2 = beanList.get(0).getStartTime();
                                Date endTime2 = beanList.get(0).getEndTime();

                                Date spedayStart2 = format3.parse(format3.format(spedayBeanList.get(k).getStartTime()));
                                Date spedayEnd2 = format3.parse(format3.format(spedayBeanList.get(k).getEndTime()));
                                int days = (int) ((spedayEnd2.getTime() - spedayStart2.getTime()) / (1000 * 3600 * 24));
                                for (int h = 0; h <= days; h++) {
                                    if (spedayStart.compareTo(startTime2) == 0 || spedayStart.before(startTime2) && (spedayEnd.compareTo(endTime2) == 0 || spedayEnd.after(endTime2))) {
                                        leaveClass += (int) Math.floor(time / 60);
                                    } else {
                                        if (spedayStart.compareTo(startTime2) == 0 || spedayStart.after(startTime2)) {
                                            // 获得两个时间的毫秒时间差异
                                            long time2 = spedayStart.getTime() - startTime2.getTime();
                                            // 计算差多少小时
                                            leaveClass += (int) Math.floor(time2 % nd / nh);
                                        } else if ((spedayStart.compareTo(startTime2) == 0 || spedayStart.before(startTime2)) && (spedayEnd.compareTo(endTime2) == 0 || spedayEnd.before(endTime2))) {
                                            //获得两个时间的毫秒时间差异
                                            long time2 = endTime2.getTime() - spedayEnd.getTime();
                                            //计算差多少小时
                                            int hours = (int) Math.floor(time2 % nd / nh);
                                            long mins = time % nd % nh / nm;
                                            int workdayTime = paramBeanList.get(0).getWorkdayTime();
                                            int workdayHours = workdayTime / 60;
                                            long workdayMins = workdayTime % 60;
                                            if (hours > 0) {
                                                leaveClass += workdayHours - hours;
                                            } else {
                                                workdayMins = 60;
                                                mins = workdayMins - mins;
                                                if (mins > 0) {
                                                    leaveClass += workdayHours - 1;
                                                } else {
                                                    leaveClass += workdayHours - 2;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }


                        AccessLogTemp accessLogTemp = new AccessLogTemp();
                        accessLogTemp.setKey("holoday" + spedayBeanList.get(k).getLeaveClassId());
                        for (int j = 0; j < leaveClassBeanList.size(); j++) {
                            if (spedayBeanList.get(k).getLeaveName() != null && spedayBeanList.get(k).getLeaveName().equals(leaveClassBeanList.get(j).getLeaveName())) {
                                //次
                                long diff = spedayBeanList.get(k).getEndTime().getTime() - spedayBeanList.get(k).getStartTime().getTime();
                                long day = diff / nd;// 计算差多少天
                                for (int h = 0; h <= day; h++) {
                                    if (leaveClassBeanList.get(j).getUnit() == 1) {
                                        thingLeave += hour;
                                        goOut++;
//                                    accessLogTemp.setValue(String.valueOf(thingLeave));
                                        accessLogTemp.setValue(thingLeave + "");//Integer.parseInt(accessLogTemp.getValue(())) +
                                    } else if (leaveClassBeanList.get(j).getUnit() == 2) {
                                        thingLeave += minute;
                                        goOut++;
                                        accessLogTemp.setValue((Integer.parseInt(accessLogTemp.getValue()) + thingLeave) + "");
                                    } else {
                                        goOut++;
                                        accessLogTemp.setValue((Integer.parseInt(accessLogTemp.getValue()) + day + 1) + "");
                                    }
                                }
                            }
                        }

                        tempArrayList.add(accessLogTemp);

//                        if (spedayBeanList.get(k).getLeaveName() != null && spedayBeanList.get(k).getLeaveName().equals("事假")) {
//                            thingLeave += hour;
//                        }
//                        if (spedayBeanList.get(k).getLeaveName() != null && spedayBeanList.get(k).getLeaveName().equals("病假")) {
//                            sickLeave += hour;
//                        }
//                        if (spedayBeanList.get(k).getLeaveName() != null && spedayBeanList.get(k).getLeaveName().equals("探亲假")) {
//                            familyLeave += hour;
//                        }
                    }
                    list.get(i).setList(tempArrayList);
                    CheckInOutBean checkInOutBean = new CheckInOutBean();
                    checkInOutBean.setUserID(userID);
                    checkInOutBean.setCheckType("2");
                    checkInOutBean.setStartTime(start);
                    checkInOutBean.setEndTime(end);
                    List<CheckInOutBean> checkInOutList = checkInOutService.findCheckInOutBeanList(checkInOutBean);
                    for (int k = 0; k < checkInOutList.size(); k++) {
                        if (checkInOutList.get(k).getCheckTime() != null && list.get(i).getEndTime() != null) {
                            Date checkTime = format2.parse(df3.format(checkInOutList.get(k).getCheckTime()));
                            if (list.get(i).getEndTime().after(checkTime)) {
                                long num = list.get(i).getEndTime().getTime() - checkTime.getTime();
                                long hour = num % nd / nh;
                                isOut += hour;
                            }
                        }
                    }
                }
            }
            list.get(i).setShouldArrive(shouldArrive);
            list.get(i).setTrueArrive(trueArrive);
            list.get(i).setLateArrive(lateArrive);
            list.get(i).setLeaveEarly(leaveEarly);
            list.get(i).setAbsenteeism(absenteeism - trueArrive - goOut);
            if (list.get(i).getAbsenteeism() < 0) {
                list.get(i).setAbsenteeism(0);
            }
            long minutes = 0;
            if (lateArriveTime != 0) {
                minutes = lateArriveTime / 60000;
                workMins = Math.toIntExact(workMins - minutes);
            }
            if (leaveEarlyTime != 0) {
                minutes = leaveEarlyTime / 60000;
                workMins = Math.toIntExact(workMins - minutes);
            }
            int time = workMins;
            double hours = (double) time / 60.0;
            list.get(i).setWorkMinsToDou(Double.valueOf(ddf1.format(hours)));
            if(list.get(i).getSchName() != null){
                if(list.get(i).getSchName().equals("加班")){
                    list.get(i).setAddWorkTime((int) hours);
                    if(weekdayAddTime == 9){
                        weekdayAddTime =(int)hours;
                    }
                }else {
                    list.get(i).setAddWorkTime(addWorkTime);
                }
            }
            list.get(i).setSignIn(signIn);
            list.get(i).setSignBack(signBack);
//            list.get(i).setNoSignIn(list.get(i).getAbsenteeism() - signIn);
            list.get(i).setNoSignIn(list.get(i).getShouldArrive() - signIn);
            if (list.get(i).getNoSignIn() < 0) {
                list.get(i).setNoSignIn(0);
            }
//            list.get(i).setNoSignBack(list.get(i).getAbsenteeism() - signBack);
            list.get(i).setNoSignBack(list.get(i).getShouldArrive() - signBack);
            if (list.get(i).getNoSignBack() < 0) {
                list.get(i).setNoSignBack(0);
            }
            list.get(i).setWeekday(weekday);
            list.get(i).setWeekend(weekend);
            list.get(i).setHoliday(holiday);
            list.get(i).setLeaveClass(leaveClass);
            if (list.get(i).getLeaveClass() < 0) {
                list.get(i).setLeaveClass(0L);
            }
            list.get(i).setIsOut(isOut);
            list.get(i).setGoOut(goOut);
            list.get(i).setThingLeave(thingLeave);
            list.get(i).setSickLeave(sickLeave);
            list.get(i).setFamilyLeave(familyLeave);
            list.get(i).setAttendanceTime(Double.valueOf(ddf1.format(attendanceTime)));
//            long time1 = weekdayAddTime / 1000 / (60 * 60);
            list.get(i).setWeekdayAddTime(weekdayAddTime);
            long time2 = weekendAddTime / 1000 / (60 * 60);
            list.get(i).setWeekendAddTime(time2);
            long time3 = holidayAddTime / 1000 / (60 * 60);
            list.get(i).setHolidayAddTime(time3);
        }


        HashMap<String, AccessLogBean> tempMap = new HashMap<String, AccessLogBean>();
        //去掉重复的key
        for (AccessLogBean investOrder : list) {
            String temp = investOrder.getUserId();//user_id相同的属性
            String userName = investOrder.getUserName();
            //containsKey(Object key)该方法判断Map集合中是否包含指定的键名，如果包含返回true，不包含返回false
            //containsValue(Object value)该方法判断Map集合中是否包含指定的键值，如果包含返回true，不包含返回false
            if (tempMap.containsKey(temp)) {
                AccessLogBean newInvestOrder = new AccessLogBean();
                newInvestOrder.setUserId(temp);
                newInvestOrder.setUserName(userName);
                newInvestOrder.setDepName(investOrder.getDepName());
                newInvestOrder.setAutoID(investOrder.getAutoID());
                newInvestOrder.setList(investOrder.getList());
                newInvestOrder.setSchName(tempMap.get(temp).getSchName() + "，" + investOrder.getSchName());

                //合并相同invest的quantity
                newInvestOrder.setShouldArrive(investOrder.getShouldArrive());
                newInvestOrder.setTrueArrive(tempMap.get(temp).getTrueArrive() + investOrder.getTrueArrive());
                newInvestOrder.setLateArrive(tempMap.get(temp).getLateArrive() + investOrder.getLateArrive());
                newInvestOrder.setLeaveEarly(tempMap.get(temp).getLeaveEarly() + investOrder.getLeaveEarly());
                newInvestOrder.setAbsenteeism(tempMap.get(temp).getAbsenteeism());// + investOrder.getAbsenteeism()
                newInvestOrder.setSignIn(tempMap.get(temp).getSignIn() + investOrder.getSignIn());
                newInvestOrder.setSignBack(tempMap.get(temp).getSignBack() + investOrder.getSignBack());
                newInvestOrder.setNoSignIn(investOrder.getNoSignIn());//(investOrder.getShouldArrive() - investOrder.getSignIn())
                newInvestOrder.setNoSignBack(investOrder.getNoSignBack());//(investOrder.getShouldArrive() - investOrder.getSignBack())
                if (tempMap.get(temp).getWorkMinsToDou() > 0 && investOrder.getWorkMinsToDou() > 0) {
                    newInvestOrder.setWorkMinsToDou(Double.valueOf(ddf1.format(tempMap.get(temp).getWorkMinsToDou() + investOrder.getWorkMinsToDou())));
                }
                if (tempMap.get(temp).getAddWorkTime() != null && investOrder.getAddWorkTime() != null) {
                    Integer time = tempMap.get(temp).getAddWorkTime() + investOrder.getAddWorkTime();
                    newInvestOrder.setAddWorkTime(time);
                }
                if (tempMap.get(temp).getIsOut() != null && investOrder.getIsOut() != null) {
                    newInvestOrder.setIsOut(tempMap.get(temp).getIsOut() + investOrder.getIsOut());
                }
                if (tempMap.get(temp).getGoOut() != null && investOrder.getGoOut() != null) {
                    newInvestOrder.setGoOut(tempMap.get(temp).getGoOut() + investOrder.getGoOut());
                }
                if (tempMap.get(temp).getLeaveClass() != null && investOrder.getLeaveClass() != null) {
                    newInvestOrder.setLeaveClass(tempMap.get(temp).getLeaveClass() + investOrder.getLeaveClass());
                }
                if (tempMap.get(temp).getThingLeave() != null && investOrder.getThingLeave() != null) {
                    newInvestOrder.setThingLeave(tempMap.get(temp).getThingLeave() + investOrder.getThingLeave());
                }
                if (tempMap.get(temp).getFamilyLeave() != null && investOrder.getFamilyLeave() != null) {
                    newInvestOrder.setFamilyLeave(tempMap.get(temp).getFamilyLeave() + investOrder.getFamilyLeave());
                }
                if (tempMap.get(temp).getSickLeave() != null && investOrder.getSickLeave() != null) {
                    newInvestOrder.setSickLeave(tempMap.get(temp).getSickLeave() + investOrder.getSickLeave());
                }
                newInvestOrder.setWeekday(tempMap.get(temp).getWeekday() + investOrder.getWeekday());
                newInvestOrder.setWeekend(tempMap.get(temp).getWeekend() + investOrder.getWeekend());
                newInvestOrder.setHoliday(tempMap.get(temp).getHoliday() + investOrder.getHoliday());
//                long hour2 = investOrder.getAttendanceTime() / 1000 / (60 * 60);
                newInvestOrder.setAttendanceTime(tempMap.get(temp).getAttendanceTime() + investOrder.getAttendanceTime());
                newInvestOrder.setWeekdayAddTime(tempMap.get(temp).getWeekdayAddTime() + investOrder.getWeekdayAddTime());
                long time22 = investOrder.getWeekendAddTime() / 1000 / (60 * 60);
                newInvestOrder.setWeekendAddTime(tempMap.get(temp).getWeekendAddTime() + time22);
                long time32 = investOrder.getHolidayAddTime() / 1000 / (60 * 60);
                newInvestOrder.setHolidayAddTime(tempMap.get(temp).getHolidayAddTime() + time32);
                //HashMap不允许key重复，当有key重复时，前面key对应的value值会被覆盖
                tempMap.put(temp, newInvestOrder);
            } else {
                //不存在重复的存入map
                if (investOrder.getUserId().equals("1002")) {
                    investOrder.setAddWorkTime(null);
                }
                tempMap.put(temp, investOrder);
            }
        }
        //去除重复key的list
        List<AccessLogBean> newList = new ArrayList<>();
        //map转list
        for (String temp : tempMap.keySet()) {
            newList.add(tempMap.get(temp));
        }

        List<AccessLogBean> count = accessLogService.findAccessLogConCount(bean);
        return LayuiUtil.data(Long.valueOf(newList.size()), newList);
    }
}
